# 使用AI自动生成数据（一些虚拟数据等）,泛化AI模型
# pip install langchain_experimental

import os

from langchain_experimental.synthetic_data import create_data_generation_chain
from langchain_openai.chat_models.base import BaseChatOpenAI

# 本地有clash代理，所以配置一下，不然一些依赖下载不下来（chroma）,或者将代理关闭后下载
os.environ['http_proxy'] = '127.0.0.1:7890'
os.environ['https_proxy'] = '127.0.0.1:7890'

os.environ["LANGCHAIN_TRACING_V3"] = "true"
os.environ["LANGCHAIN_API_KEY"] = "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"
os.environ["LANGCHAIN_PROJECT"] = "langchain-community-demo"

os.environ["OPENAI_API_KEY"] = "sk-1dd16a258a73428d910d38c782e1c94f"

# deepseek-reasoner : DeepSeek-R1
# deepseek-chat : DeepSeek-V3
model_name = "deepseek-chat"
deepseek_api_key = "sk-1dd16a258a73428d910d38c782e1c94f"

model = BaseChatOpenAI(
    model=model_name,
    openai_api_key=deepseek_api_key,
    openai_api_base='https://api.deepseek.com',
    max_tokens=1024,
    streaming=True,
    temperature=0.7,
)

# 创建链
chain = create_data_generation_chain(model)

# 生成数据
# result = chain(
#     # 给一些关键词，随机生成一句话
#     {
#         'fields': ['天空，蓝色，黄色'],
#         'preferences': {}
#     }
# )

result = chain(
    # 给一些关键词，随机生成一句话
    {
        'fields': ['天空，蓝色，黄色'],
        'preferences': {"style": "像诗歌一样"}
    }
)

print(result)



